﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Configuration;

namespace outREACH.App_Code
{
    public class Avatars
    {
        public string imagePath { get; set; }
        public string imageName { get; set; }

        public static List<Avatars> GetAvatars()
        {
            SqlConnection conn = null;
            List<Avatars> results = new List<Avatars>();
            try
            {
                conn = new SqlConnection();
                SqlCommand comm = new SqlCommand();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["outreachdbConnectionString"].ConnectionString;
                conn.Open();
                comm.Connection = conn;
                comm.CommandText = "select * from Avatars";
                SqlDataReader dr = comm.ExecuteReader();
                while (dr.Read())
                {
                    Avatars a = new Avatars();
                    a.imageName = (string)dr["imageName"];
                    a.imagePath = (string)dr["imagePath"];
                    results.Add(a);
                }
                dr.Close();
            }
            catch (SqlException ex)
            {
                throw ex;
            }
            finally
            {
                conn.Close();
            }
            return results;
        }
    }
}